unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, SAX, BSAX;

type
  TForm1 = class(TForm)
    ComboBox1: TComboBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    labDesc: TLabel;
    labVal: TLabel;
    labNamespaces: TLabel;
    labPrefixes: TLabel;
    labGenEnt: TLabel;
    labParamEnt: TLabel;
    Label8: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  // Fill the list
  ListSAXVendors(ComboBox1.Items);
  // Set the item index
  ComboBox1.ItemIndex:= ComboBox1.Items.IndexOf(DefaultSAXVendor);
  // Fire the OnChange event manually
  ComboBox1Change(ComboBox1);
end;

function GetFeature(Feature: SAXString; XMLReader: IUnknown;
  Buffered: Boolean): Boolean;
begin
  if Buffered then
    Result:= IBufferedXMLReader(XMLReader).Features[Feature]
  else
    Result:= IXMLReader(XMLReader).Features[Feature];
end;

procedure TForm1.ComboBox1Change(Sender: TObject);
var
  AVendor: TSAXVendor;
  AXMLReader : IUnknown;
  Buffered: Boolean;
begin
  // Check to make sure something is selected
  if (ComboBox1.ItemIndex = -1) then
    Exit;

  // Get the vendor
  AVendor:= GetSAXVendor(ComboBox1.Items[ComboBox1.ItemIndex]);

  // Get the description
  labDesc.Caption:= AVendor.Description;

  // Get the XML Reader
  Buffered:= AVendor is TBufferedSAXVendor;
  if Buffered then
    AXMLReader:= TBufferedSAXVendor(AVendor).BufferedXMLReader
  else
    AXMLReader:= AVendor.XMLReader;

  try
    // Check for the feature
    if GetFeature(ValidationFeature, AXMLReader, Buffered) then
      labVal.Caption:= 'Yes'
    else
      labVal.Caption:= 'No';
  except
    on e : ESAXNotRecognizedException do
    begin
      // The XMLReader didn't recognize the feature
      labVal.Caption:= 'Not recognized'
    end;
    on e2 : ESAXNotSupportedException do
    begin
      // The XMLReader doesn't support querying this feature right now
      labVal.Caption:= 'Not supported'
    end;
  end;

  try
    // Check for the feature
    if GetFeature(NamespacesFeature, AXMLReader, Buffered) then
      labNamespaces.Caption:= 'Yes'
    else
      labNamespaces.Caption:= 'No';
  except
    on e : ESAXNotRecognizedException do
    begin
      // The XMLReader didn't recognize the feature
      labNamespaces.Caption:= 'Not recognized'
    end;
    on e2 : ESAXNotSupportedException do
    begin
      // The XMLReader doesn't support querying this feature right now
      labNamespaces.Caption:= 'Not supported'
    end;
  end;

  try
    // Check for the feature
    if GetFeature(NamespacePrefixesFeature, AXMLReader, Buffered) then
      labPrefixes.Caption:= 'Yes'
    else
      labPrefixes.Caption:= 'No';
  except
    on e : ESAXNotRecognizedException do
    begin
      // The XMLReader didn't recognize the feature
      labPrefixes.Caption:= 'Not recognized'
    end;
    on e2 : ESAXNotSupportedException do
    begin
      // The XMLReader doesn't support querying this feature right now
      labPrefixes.Caption:= 'Not supported'
    end;
  end;

  try
    // Check for the feature
    if GetFeature(ExternalGeneralFeature, AXMLReader, Buffered) then
      labGenEnt.Caption:= 'Yes'
    else
      labGenEnt.Caption:= 'No';
  except
    on e : ESAXNotRecognizedException do
    begin
      // The XMLReader didn't recognize the feature
      labGenEnt.Caption:= 'Not recognized'
    end;
    on e2 : ESAXNotSupportedException do
    begin
      // The XMLReader doesn't support querying this feature right now
      labGenEnt.Caption:= 'Not supported'
    end;
  end;

  try
    // Check for the feature
    if GetFeature(ExternalParameterFeature, AXMLReader, Buffered) then
      labParamEnt.Caption:= 'Yes'
    else
      labParamEnt.Caption:= 'No';
  except
    on e : ESAXNotRecognizedException do
    begin
      // The XMLReader didn't recognize the feature
      labParamEnt.Caption:= 'Not recognized'
    end;
    on e2 : ESAXNotSupportedException do
    begin
      // The XMLReader doesn't support querying this feature right now
      labParamEnt.Caption:= 'Not supported'
    end;
  end;

end;

end.
